package cn.jhc.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.controller.Cart;

@WebServlet(name="Del the shopcart", urlPatterns= {"/delshopcart.do"})
public class ShopCartDelServlet extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String isbn = req.getParameter("isbn");
		Cart cart = (Cart)req.getSession().getAttribute("cart");
		if(cart == null) {
			cart = new Cart();
			req.getSession().setAttribute("cart", cart);
		}
		cart.addDelCart(isbn);
		RequestDispatcher dispatcher = req.getRequestDispatcher("/shop.jsp");
		dispatcher.forward(req, resp);
	}
}
